﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="storagelist.aspx.cs" Inherits="UI.system.page.storage.storagelist" %>
<%@ Import Namespace="Model" %>
<%@ Import Namespace="DAL" %>
<%@ Import Namespace="Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="/system/js/jquery.min.js"></script>
    <script src="/system/js/common.js"></script>
    <script src="/system/js/md5.js"></script>
    <script src="/system/js/swfupload.js"></script>
    <script src="/system/js/admin.js"></script>
    <script src="/system/layui/layui.js"></script>

    <script src="/Lodop/LodopFuncs.js" type="text/javascript"></script>

    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
    <style>
        td img{border-radius:20px; width:40px; height:40px; float:left; margin-left:5px;}        
        .layer-toolbar-left div,.layer-toolbar-left div span,.layer-toolbar-left div input{ float:left;}
        .layer-toolbar layui-form{ z-index:999;}
        .layer-toolbar-left div span{ line-height:38px;}
        .layer-toolbar-left div input{ width:130px; height:32px;margin:3px 10px 0 4px;line-height: 32px;}
        .layui-btn-small{ margin-top:4px;}
        #oa_power{ margin-top:60px;}
        .userinfo{ display:block; margin-bottom:20px;}/* 是否显示 */        
        .tables{ border:0px; margin-top:20px;}
        .tables_left{ border-left:0px;}.tables_right{ border-right:0px;}
        .userinfo table tr{ border-color:#e2e2e2;}.userinfo table tr{ background-color:#fff; line-height:30px;}.userinfo table tr td{ width:1%; height:35px; line-height:35px;}.userinfo table tr td .ty_div{ margin-left:10px;}
        .ty{ height:30px; line-height:30px; width:100%; padding-left:1%;}.ty .ty_div{ float:left; width:33%;/*overflow: hidden; white-space: nowrap; text-overflow: ellipsis;*/}.ty div .names{ float:left; height:100%;} .ty div span{ margin:0 8px 0 5px;word-break: break-all;word-wrap: break-word;}
        .tyimg{ height:80px; width:100%; line-height:80px; margin:10px 0px;}
        
        .main{ height:100%; width:75%; margin-left:10px; float:left;}
        #img_k{width:100%;  height:auto;  position:relative;}
        #img_panel,.img_panel_jp,.img_panel_hp{width:auto; height:auto;}
        #img_panel  div,.img_panel_jp  div,.img_panel_hp  div{ float:left; margin-right:15px; position:relative; }
        #img_panel  div img,.img_panel_jp  div img,.img_panel_hp  div img{width:80px; height:80px; overflow:hidden; float:left; text-align:left; border:1px solid #cdcdcd; object-fit: cover;}
        #img_panel  div .delete,.img_panel_jp  div .delete,.img_panel_hp  div .delete{cursor:pointer; position:absolute; padding:0px; right:-20px; top:-8px; width:20px; height:20px; background:url(/system/img/delete.png);}
        #img_panel  div .delete img,.img_panel_jp  div .delete img,.img_panel_hp  div .delete img{border:0px; width:20px; height:20px;}
        #img_panel #add-photo, .img_panel_jp .add-photo_jp ,.img_panel_hp .add-photo_hp{width:80px; height:80px; background-image:url(/system/img/add-photo.png); background-size:80px 80px;  padding-top:10px; float:left;}    
        .upload_img{ padding-top:8px;}
        #ruku_btn_show,#jiepian_btn_show,#huanpian_btn_show,#yuanshishuju,#shouciruku{ display:none;}     
        
        .imgview{ margin:0px;}
    </style>
</head>
<body>
    
    <form id="form1" runat="server">
    <div class="layer-toolbar layui-form" style="z-index: 99999;">
        <div class="layer-toolbar-left">
           <%-- <%=MenuDAL.Power("Save") %>--%>
           <div><span>主条码：</span><input id="code" type="text" name="title" placeholder="请输入主条码" autocomplete="off" class="layui-input" value=""></div>
           <div><span>姓名：</span><input id="name" type="text" name="title" placeholder="请输入姓名" autocomplete="off" class="layui-input" value=""></div>
           <div><span>病理号：</span><input id="bingli" type="text" name="title" placeholder="请输入病理号" autocomplete="off" class="layui-input" value=""></div>
           <div><span>医院：</span><input id="yiyuan" type="text" name="title" placeholder="请输入医院" autocomplete="off" class="layui-input" value=""></div>
           
           <a id="search" class="layui-btn layui-btn-small layui-btn-normal" onclick="Searchs()">搜索</a>
           <a id="dayins" class="layui-btn layui-btn-small layui-btn-normal" onclick="myPreview2()" style=" height:30px; margin-left:8px;">打印</a>
           &nbsp;
           <span id="ruku_btn_show"><a class="layui-btn layui-btn-small  layui-btn-warm" onclick="ruku();">首次入库</a></span>
           <span id="jiepian_btn_show"><a class="layui-btn layui-btn-small  layui-btn-warm" onclick="jiepian();">借片</a></span>
           <span id="huanpian_btn_show"><a class="layui-btn layui-btn-small  layui-btn-warm" onclick="huanpian();">还片</a></span>           
        </div>
        <div class="layer-toolbar-right">
            
        </div>
    </div>
    </form>
        <div id="lists">
        <div class="userinfo" id="yuanshishuju">
        <fieldset id="oa_power" class="layui-elem-field site-demo-button">
            <legend style="padding:0 8px; color:Red;">原始数据</legend>
                <div id="ys_id" style=" display:none;"></div>
               <table border="1" class="tables">                    
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_experimentnumber">实验号：<span></span></div></td>
                    <td><div class="ty_div" id="ys_name">姓名：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_ucode">主条码：<span></span></div>   </td>                 
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_bpcount">玻片数量：<span></span></div></td>
                    <td><div class="ty_div" id="ys_lkcount">蜡块数量：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_blcode">病理号：<span></span></div></td>
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_sexs">性别：<span></span></div></td>
                    <td><div class="ty_div" id="ys_age">年龄：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_opinions">诊断意见：<span></span></div>      </td>              
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_reportdoctor">报告医生：<span></span></div></td>
                    <td><div class="ty_div" id="ys_tuwenshu">图文数：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_datuwenshu">大体图文数：<span></span></div>   </td>                 
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_entryname">项目名称：<span></span></div></td>
                    <td><div class="ty_div" id="ys_process">病理流程：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_state">状态：<span></span></div>     </td>               
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_late">迟：<span></span></div></td>
                    <td><div class="ty_div" id="ys_delayedcause">迟发原因：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_outsourcingparty">外包方：<span></span></div>   </td>                 
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_termination">终止：<span></span></div></td>
                    <td><div class="ty_div" id="ys_terminationreason">终止原因：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_back">退单：<span></span></div>     </td>               
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_backreason">退单原因：<span></span></div></td>
                    <td><div class="ty_div" id="ys_submitter">提交人：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_auditor">审核人：<span></span></div></td>
                </tr>
                <tr>
                    <td class="tables_left"><div class="ty_div" id="ys_referencedoctor">取材医生：<span></span></div></td>
                    <td><div class="ty_div" id="ys_specimensigningtime">标本签收时间：<span></span></div></td>
                    <td class="tables_right"><div class="ty_div" id="ys_remarks">备注：<span></span></div> </td>                   
                </tr>
                <tr>
                    <td class="tables_right,table_left" colspan="3" style="border:0px;"><div class="ty_div" id="ys_hospital">医院：<span></span></div></td>
                </tr>
            </table>           
        </fieldset>
    </div>
        <div class="userinfo" id="shouciruku">
            <fieldset id="Fieldset1" class="layui-elem-field site-demo-button">
              <legend style="padding:0 8px;color:Red;">首次入库</legend>
                
                <table border="1" class="tables">
                    <tr>
                        <td class="tables_left"><div class="ty_div" id="rk_username">姓名：<span></span></div></td>
                        <td><div class="ty_div" id="rk_aname">操作人：<span></span></div></td>
                        <td class="tables_right"><div class="ty_div" id="rk_adate">操作时间：<span></span></div></td>
                    </tr>
                    <tr>
                        <td class="tables_left"><div class="ty_div" id="rk_bpcount">玻片数量：<span></span></div></td>
                        <td><div class="ty_div" id="rk_lkcount">蜡块数量：<span></span></font></div></td>
                        <td class="tables_right"><div class="ty_div" id="rk_pcode">仓位编码：<span></span></div></td>
                    </tr>
                    <tr>
                        <td class="tables_left"><div class="ty_div" id="rk_createdate">入库日期：<span></span></div></td>
                        <td class="tables_right" colspan="2"><div class="ty_div" id="rk_remarks" style="width:66%;">备注：<span></span></div></td>
                    </tr>
                </table>          
                <div class="tyimg" style="padding-left:1%;">
                    <div style="float:left;" class="dy_imgs">图片：</div>
                    <div class="main">
                        <div id="img_k"><div id="img_panel" class="imgview"></div><div id="add-photo"></div></div>
                    </div>  
                </div>
            <%--</div> --%>
            </fieldset>
        </div>

</div>
    <script>
        
        layui.use(["form", "table", "laydate"], function () {
            var $ = layui.jquery, form = layui.form, laydate = layui.laydate;
            table = layui.table;
            laydate.render({
                elem: '#begindate'
            });
            laydate.render({
                elem: '#enddate'
            });
            //Init_Pager();
            
        });

//        function Init_Pager(pageindex) {
//            var data = {};
//            data.act = "Find_Journal";
//            data.pageindex = pageindex;
//            data.parentid = $(".layui-table").attr("parentid");
//            data.begindate = $("#begindate").val();
//            data.enddate = $("#enddate").val();
//            data.keyword = $("#keyword").val();
//            data.sign = GetSign(data.act);
//            table.reload('mytable', {
//                url: '/tools/Admin.ashx',
//                loading: true,
//                where: data
//            });
//        };
        var pocode;
        function ruku() {
            
            var name = $("#ys_name span").html();
            var code = $("#ys_ucode span").html(); 
            var rawid =  $("#ys_id").html();
                if(rawid>0){
                LayerBox.Loading();
                Ajax.Get("/system/page/storage/rukuadd.aspx?id=" + code + "&name=" + name + "&v=" + Math.random(), function (html) {
                    LayerBox.Close.ByAll();
                    var title = "首次入库";
                    window.parent.LayerBox.Show(title + "", html, 550, 620, null, function (form) {
                        var fo = true;
                        if (isNaN(form.bpcount)) {
                            LayerBox.Error("请输入正确的玻片数量");
                            fo = false;
                        } else if (isNaN(form.lkcount)) {
                            LayerBox.Error("请输入正确的蜡块数量");
                            fo = false;
                        } else if (form.pid == "请选择" || form.pid == null || form.pid < 0) {
                            LayerBox.Error("请输入正确的仓位编码");
                            fo = false;
                        } else if (fo == true) {
                            var data = form;
                            data.act = "Save_Ruku";
                            data.pid = form.pid;
                            data.ucode = code;
                            data.name = name;
                            data.rawid = rawid;
                            var st = new Array();
                            window.parent.$("#img_panel img").each(function () { //jquery.each()循环读取所有图片  
                                if ($(this).attr("src") != "/system/img/delete.png") {
                                    st.push($(this).attr("src"));
                                }
                            });
                            data.Imgs = st.join(',');
                            data.sign = GetSign(data.act);
                            LayerBox.Loading();
                            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                                var json = $.parseJSON(r);
                                if (json.state) {
                                    LayerBox.Close.ByAll();
                                    LayerBox.Success(json.msg, 500, function () {
                                        $("#shouciruku").show();
                                        $("#ruku_btn_show").hide();

                                        $("#jiepian_btn_show").show();


                                        Searchs();
                                    });

                                }

                                else {                                    
                                    LayerBox.Error(json.msg);
                                }
                            });
                        }
                    });
                });
               
            }else{
                LayerBox.Error("请选择要添加的主条码");
            }
        }
        function jiepian() {
            var name = $("#ys_name span").html();
            var code = $("#ys_ucode span").html();   
            var rawid =  $("#ys_id").html();       
                if(rawid>0){
                    LayerBox.Loading();
                    Ajax.Get("/system/page/storage/jiepianadd.aspx?id=" + rawid + "&&code=" + code + "&v=" + Math.random(), function (html) {
                        LayerBox.Close.ByAll();
                        var title = "借片";
                        window.parent.LayerBox.Show(title + "", html, 630, 730, null, function (form) {
                            var fo = true;
                            if (!Validate.IsNumber(form.bpcount) && form.bpcount != 0) {
                                LayerBox.Error("请输入正确的玻片数量");
                                return;
                            } else if (!Validate.IsNumber(form.lkcount) && form.lkcount!=0) {
                                LayerBox.Error("请输入正确的蜡块数量");
                                return;
                            } else if (!Validate.IsMobile(form.mobile)) {
                                LayerBox.Error("请输入正确的手机号");
                                fo = false;
                                alert("手机号");
                            } else if (form.pid == "" || form.pid == null || form.pid < 0) {
                                LayerBox.Error("请输入正确的仓位编码");
                                fo = false;
                                alert("编码");
                            } else if (fo == true) {
                                var data = form;
                                data.act = "Save_Jiepian";
                                data.pid = form.pid;
                                data.ucode = code;
                                data.rawid = rawid;
                                var st = new Array();
                                window.parent.$("#img_panel img").each(function () { //jquery.each()循环读取所有图片  
                                    if ($(this).attr("src") != "/system/img/delete.png") {
                                        st.push($(this).attr("src"));
                                    }
                                });
                                data.Imgs = st.join(',');
                                data.sign = GetSign(data.act);
                                LayerBox.Loading();
                                Ajax.Post("/tools/Admin.ashx", data, function (r) {
                                    var json = $.parseJSON(r);
                                    if (json.state) {
                                        LayerBox.Close.ByAll();
                                        LayerBox.Success(json.msg, 500, function () {
                                            $("#jiepian").show();
                                            $("#jiepian_btn_show").hide();
                                            $("#huanpian_btn_show").show();

                                            Searchs();
                                        });

                                    }
                                    else {
                                        LayerBox.Error(json.msg);
                                    }
                                });
                            }
                        });
                    });
            }else{
                LayerBox.Error("请选择主条码");
            }
        }
        function huanpian() {
            var name = $("#ys_name span").html();
            var code = $("#ys_ucode span").html(); 
            var rawid =  $("#ys_id").html();         
                if(rawid>0){
                LayerBox.Loading();
                Ajax.Get("/system/page/storage/huanpianadd.aspx?id=" + rawid + "&&code=" + code + "&v=" + Math.random(), function (html) {
                    LayerBox.Close.ByAll();
                    var title = "还片";
                    window.parent.LayerBox.Show(title + "", html, 630, 730, null, function (form) {
                        var fo = true;
                        if (!Validate.IsNumber(form.bpcount) && form.bpcount != 0) {
                            LayerBox.Error("请输入正确的玻片数量");
                            return;
                        } else if (!Validate.IsNumber(form.lkcount) && form.lkcount != 0) {
                            LayerBox.Error("请输入正确的蜡块数量");
                            return;
                        } else if (!Validate.IsMobile(form.mobile)) {
                            LayerBox.Error("请输入正确的手机号");
                            fo = false;
                        } else if (form.pid == "" || form.pid == null || form.pid < 0) {
                            LayerBox.Error("请输入正确的仓位编码");
                            fo = false;
                        } else if (fo == true) {
                            var data = form;
                            data.act = "Save_Huanpian";
                            data.pid = form.pid;
                            data.ucode = code;
                            data.rawid = rawid;
                            var st = new Array();
                            window.parent.$("#img_panel img").each(function () { //jquery.each()循环读取所有图片  
                                if ($(this).attr("src") != "/system/img/delete.png") {
                                    st.push($(this).attr("src"));
                                }
                            });
                            data.Imgs = st.join(',');
                            data.sign = GetSign(data.act);
                            LayerBox.Loading();
                            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                                var json = $.parseJSON(r);
                                if (json.state) {
                                    LayerBox.Close.ByAll();
                                    LayerBox.Success(json.msg, 500, function () {
                                        $("#huanpian").show();
                                        $("#huanpian_btn_show").hide();
                                        Searchs();
                                    });
                                }
                                else {
                                    LayerBox.Error(json.msg);
                                }
                            });
                        }
                    });
                });
            }else{
                LayerBox.Error("请选择主条码");
            }            
        }
        var ruk=false;
        var huanp=false;
        var jiep=false;
        function Searchs() { //搜索按钮
            $("#yuanshishuju").hide();
            $("#ruku_btn_show").hide();
            $("#jiepian_btn_show").hide();
            $("#huanpian_btn_show").hide();
            $("#shouciruku").hide();
            $("#jiepian").hide();
            $("#huanpian").hide();

            $(".userinfo").hide();

            var code = $("#code").val();
            var name = $("#name").val();
            var bingli = $("#bingli").val();
            var yiyuan = $("#yiyuan").val();

            if(code=="" && name=="" && bingli=="" && yiyuan==""){
                LayerBox.Error("请输入信息再查询");
                $("#lists").hide();

            } else {
                $("#lists").show();        
                find_yuanshishuju(code,name,bingli,yiyuan);
                //find_ruku(code);
            }
        }
        /* 查询信息 */
        function find_yuanshishuju(code,name,bingli,yiyuan) {
            var data = {};
            data.act = "Find_RawdataByucode";
            data.ucode = code;
            data.name = name;
            data.blcode = bingli;
            data.hospital = yiyuan;
            data.sign = GetSign(data.act);
            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    yuanshishujudata(json.data);
                    $("#yuanshishuju").show();
                    //$("#dayins").show();
                    var name = $("#ys_name span").html();
                    var codes = $("#ys_ucode span").html();
                    find_ruku(codes, json.data.ID);
                }
                else {                    
                    LayerBox.Error(json.msg);
                }
            });
        }
        function find_ruku(codes,rawid){   //根据code 查询入库信息           
            var data = {};
            data.act = "Find_Ruku";
            data.ucode = codes;
            data.rawid = rawid;
            data.sign = GetSign(data.act);
            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {   //如果存在信息，显示借片按钮                    
                    $("#shouciruku").show();
                    rukudata(json.data);
                    rukus(json.data.ID, json.data.Imgs);

                    find_all(codes, rawid);
                }
                else {  //否则显示入库按钮
                    $("#ruku_btn_show").show();
                }
            });
        }
        function find_all(codes, rawid) {
            var data = {};
            data.act = "Find_JPAndHP";
            data.ucode = codes;
            data.rawid = rawid;
            data.sign = GetSign(data.act);
            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    if (json.data.jplist.length >= json.data.hplist.length) {
                        $('div[name=jiepian]').remove();
                        $('div[name=huanpian]').remove();
                        for (var i = 0; i < json.data.jplist.length; i++) {
                            /*这是借片显示信息 */
                            var len = 0;
                            $('div[name=jiepian]').each(function () {
                                len = len + 1;
                            });
                            if (len == json.data.jplist.length) {
                                $('div[name=jiepian]').show();
                            } else if (i <= json.data.jplist.length) {
                                addjiepian(json.data.jplist[i], (i + 1));
                                /*图片信息*/
                                jiepianimg(json.data.jplist[i].ID, json.data.jplist[i].Imgs, (i + 1));
                            }

                            /*这是还片显示信息*/
                            var lens = 0;
                            $('div[name=huanpian]').each(function () {
                                lens = lens + 1;
                            });
                            if (lens == json.data.hplist.length) {
                                $('div[name=huanpian]').show();
                            } else if (i <= json.data.hplist.length) {
                                addhuanpian(json.data.hplist[i], (i + 1));
                                /*图片信息*/
                                huanpianimg(json.data.hplist[i].ID, json.data.hplist[i].Imgs, (i + 1));
                            }
                            if (i == (json.data.hplist.length - 1) && json.data.hplist.length == json.data.jplist.length) {
                                $("#huanpian_" + (i + 1)).attr("style", "margin-bottom:60px;");

                            } else if (i == (json.data.jplist.length) - 1) {
                                $("#jiepian_" + (i + 1)).attr("style", "margin-bottom:60px;");
                            }
                        }

                    } else {
                        LayerBox.Error("信息异常");
                    }
                    showbtn(json.data.jplist.length, json.data.hplist.length);
                } else {
                    $("#jiepian_btn_show").show();
                }                
            });

        }

        function showbtn(jpbtn, hpbtn) {
            if (jpbtn == hpbtn) {
                $("#huanpian_btn_show").hide();
                $("#jiepian_btn_show").show();
            }
            else if (jpbtn > hpbtn) {
                $("#jiepian_btn_show").hide();
                $("#huanpian_btn_show").show();
            } else if (jpbtn < hpbtn) {
                $("#huanpian_btn_show").hide();
                $("#jiepian_btn_show").show();
            }
        }

        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
//            if (e && e.keyCode == 27) { // 按 Esc 
//                //要做的事情
//            }
//            if (e && e.keyCode == 113) { // 按 F2 
//                //要做的事情
//            }
            if (e && e.keyCode == 13) { // enter 键
                Searchs();
            }
        };
        function rukus(id,imgs) {
            $('#img_k').html('<div id="img_panel" class="imgview"></div><div id="add-photo"></div>');
            if(imgs!="" && imgs!=null){
                var st = imgs;
                var str = new Array();
                str = st.replace(':', '-').toString().split(',');
                var html = "";                
                for(var i=0;i<str.length;i++){
                    html += '<div id="Imgs"><img data-original="' + str[i] + '" src="' + str[i] + '"/><input type="hidden" value="' + str[i] + '"><div id="' + str[i] + '" class="delete" onclick="RemoveImgs_rk(this,' + id + ')"></div></div>';
                }
                $("#img_panel").html(html);   
            }else{
                var html = '<div id="Imgs"></div>';
                $("#img_panel").html(html);
            }
            var upload = new Upload_File("add-photo", null, 80, 80, "/system/img/add-photo.png", true);
            upload.swfu.handle = "upload_annex";
            upload.swfu.id = id;
        };


        function jiepianimg(id, Imgs, num) {  
            //$("#img_panel_jp_1").html('<div id="img_panel_jp_' + num + '" class="imgview"></div><div id="add-photo_jp_' + num + '"></div>');            
            $('#img_jp_' + num + '').html('<div id="img_panel_jp_' + num + '" class="imgview" style="margin-right:0px;"></div><div id="add-photo_jp_' + num + '" class="add-photo_jp"></div>');            
            if(Imgs!="" && Imgs!=null){
                var st = Imgs;
                var str = new Array();
                str = st.replace(':', '-').toString().split(',');
                var html = "";
                for (var i = 0; i < str.length; i++) {
                    html += '<div id="img_jp_' + num + '"><img data-original="' + str[i] + '" src="' + str[i] + '"/><input type="hidden" value="' + str[i] + '"><div id="' + str[i] + '" class="delete" onclick="RemoveImgs_jp(this,' + id + ')"></div></div>';
                }
                $("#img_panel_jp_"+num).html(html);
            } else {
                var html = '<div id="img_jp_'+num+'"></div>';
                $("#img_panel_jp_"+num).html(html);
            }

            var uploadjp = new Upload_File("add-photo_jp_"+num, null, 80, 80, "/system/img/add-photo.png", true);
            uploadjp.swfu.handle = "upload_annex_jp";
            uploadjp.swfu.id = id;
            uploadjp.swfu.num = num;
            
           }

        function huanpianimg(id,Imgs,num){
            $('#img_hp_' + num).html('<div id="img_panel_hp_' + num + '" class="imgview" style="margin-right:0px;"></div><div id="add-photo_hp_' + num + '" class="add-photo_hp"></div>');
            if (Imgs != "" && Imgs != null) {
                var st = Imgs;
                var str = new Array();
                str = st.replace(':','-').toString().split(',');
                var html = "";
                for (var i = 0; i < str.length; i++) {
                    html += '<div id="img_hp_' + num + '"><img data-original="' + str[i] + '" src="' + str[i] + '"/><input type="hidden" value="' + str[i] + '"><div id="' + str[i] + '" class="delete" onclick="RemoveImgs_hp(this,' + id + ')"></div></div>';
                }
                $("#img_panel_hp_" + num).html(html);
            } else {
                var html = '<div id="img_hp_' + num + '"></div>';
                $("#img_panel_hp_" + num).html(html);
            }

            var uploadhp = new Upload_File("add-photo_hp_"+num, null, 80, 80, "/system/img/add-photo.png", true);
            uploadhp.swfu.handle = "upload_annex_hp";
            uploadhp.swfu.id = id;
            uploadhp.swfu.num = num;
        }

        function yuanshishujudata(o) {
            $("#ys_id").html(o.ID);
            $("#ys_name span").html(o.Name);
            $("#ys_ucode span").html(o.UCode);
            $("#ys_blcode span").html(o.BLCode);
            $("#ys_bpcount span").html(o.BPCount);
            $("#ys_lkcount span").html(o.LKCount);
            $("#ys_hospital span").html(o.Hospital);
            $("#ys_remarks span").html(o.Remarks);

            $("#ys_experimentnumber span").html(o.ExperimentNumber);

            if (o.Sex == 1) {
                $("#ys_sexs span").html("女");
            } else {
                $("#ys_sexs span").html("男");
            }

            $("#ys_age span").html(o.Age);
            $("#ys_opinions span").html(o.Opinions);
            $("#ys_reportdoctor span").html(o.ReportDoctor);
            $("#ys_tuwenshu span").html(o.TuWenShu);
            $("#ys_datuwenshu span").html(o.DaTuWenShu);
            $("#ys_entryname span").html(o.EntryName);
            $("#ys_process span").html(o.Process);
            $("#ys_state span").html(o.State);
            $("#ys_late span").html(o.Late);
            $("#ys_delayedcause span").html(o.DelayedCause);
            $("#ys_outsourcingparty span").html(o.OutsourcingParty);
            $("#ys_termination span").html(o.Termination);
            $("#ys_terminationreason span").html(o.TerminationReason);
            $("#ys_back span").html(o.Back);
            $("#ys_backreason span").html(o.BackReason);
            $("#ys_submitter span").html(o.Submitter);
            $("#ys_auditor span").html(o.Auditor);
            $("#ys_referencedoctor span").html(o.ReferenceDoctor);
            $("#ys_specimensigningtime span").html(o.SpecimenSigningTime);
        }

        function rukudata(o){
            $("#rk_username span").html(o.Name);
            $("#rk_aname span").html(o.AName);
            $("#rk_adate span").html(o.CreateDate);
            $("#rk_bpcount span").html(o.BPCount);
            $("#rk_lkcount span").html(o.LKCount);
            $("#rk_pcode span").html(o.PIDText);
            $("#rk_createdate span").html(o.CreateDate);
            $("#rk_remarks span").html(o.Remarks);
            
            $("#img_panel").html();
        }

        function RemoveImgs_rk(o, id) {
            LayerBox.Confirm("您确定要删除吗？", function () {                
                var data = {};
                data.act = "Delete_Ruku_Imgs";
                data.id = id;
                data.imgs = o.id;
                data.sign = GetSign(data.act);
                Ajax.Post("/tools/Admin.ashx", data, function (r) {                    
                    var json = $.parseJSON(r);
                    if (json.state) {
                        LayerBox.Success(json.msg, 500, function () {
                            $(o).parent().remove();
                        });                       
                    }
                    else {
                        LayerBox.Error(json.msg);
                    }
                });
            });
        }
        function RemoveImgs_jp(o, id) {
            LayerBox.Confirm("您确定要删除吗？", function () {
                var data = {};
                data.act = "Delete_Jiepian_Imgs";
                data.id = id;
                data.imgs = o.id;
                data.sign = GetSign(data.act);
                Ajax.Post("/tools/Admin.ashx", data, function (r) {
                    var json = $.parseJSON(r);
                    if (json.state) {
                        LayerBox.Success(json.msg, 500, function () {
                            $(o).parent().remove();
                        });
                    }
                    else {
                        LayerBox.Error(json.msg);
                    }
                });
            });
        }
        function RemoveImgs_hp(o,id) {
            LayerBox.Confirm("您确定要删除吗？", function () {
                var data = {};
                data.act = "Delete_Huanpian_Imgs";
                data.id = id;
                data.imgs = o.id;
                data.sign = GetSign(data.act);
                Ajax.Post("/tools/Admin.ashx", data, function (r) {
                    var json = $.parseJSON(r);
                    if (json.state) {
                        LayerBox.Success(json.msg, 500, function () {
                            $(o).parent().remove();
                        });
                    }
                    else {
                        LayerBox.Error(json.msg);
                    }
                });
            });
        }
       
       /* 追加数据 */
        function addjiepian(o, i) {
            var html ='';
            html+='<div class="userinfo" name="jiepian" id="jiepian_'+i+'" style="display:block;">';
            html+='<fieldset id="Fieldset2" class="layui-elem-field site-demo-button">';
            html+='<legend style="padding:0 8px;color:Red;">第 '+i;
            html+=' 次借片</legend>';
            html+='<table border="1" class="tables">';
            html+='<tr>';
            html+='<td class="tables_left"><div class="ty_div">借片人：<span>'+o.JPName;
            html+='</span></div></td>';
            html+='<td><div class="ty_div">操作人：<span>'+o.AName;
            html+='</span></div></td>';
            html+='<td class="tables_right"><div class="ty_div">操作时间：<span>'+o.CreateDate;
            html+='</span></div></td>';
            html+='</tr>';
            html+='<tr>';
            html+='<td class="tables_left"><div class="ty_div" id="jp_bpcount">玻片数量：<span>'+o.BPCount;
            html+='</span></div></td>';
            html+='<td><div class="ty_div">蜡块数量：<span>'+o.LKCount;
            html+='</span></div></td>';
            html+='<td class="tables_right"><div class="ty_div">仓位编码：<span>'+o.PIDText;
            html+='</span></div></td>';
            html+='</tr>';
            html+='<tr>';
            html+='<td class="tables_left"><div class="ty_div" id="jp_createdate">借片日期：<span>'+o.JPDate;
            html+='</span></div></td>';
            html+='<td><div class="ty_div">借片电话：<span>'+o.Mobile;
            html+='</span></div></td>';
            html+='<td class="tables_right"><div class="ty_div">备注：<span>'+o.Remarks;
            html+='</span></div></td>';
            html+='</tr>';
            html += '</table> ';

            html+='<div class="tyimg" style="padding-left:1%;">';
            html += '<div style="float:left;" class="dy_imgs">图片：</div>';
            html += '<div class="main">';
            html += '<div id="img_jp_' + i + '" class="img_panel_jp"><div id="img_panel_jp_' + i + '" class="imgview" style="margin-right:0px;"></div><div id="add-photo_jp_' + i + '" class="add-photo_jp"></div></div>';
            html+='</div>';
            html+='</div>';
            html+='</fieldset>';
            html+='</div>';

            $("#lists").append(html);
            //alert("第"+i+"次信息");
        }
        /* 追加数据 */
        function addhuanpian(o, i) {
            var html = '';
            html += '<div class="userinfo" name="huanpian" id="huanpian_'+i+'">';
            html += '<fieldset id="Fieldset3" class="layui-elem-field site-demo-button">';
            html += '<legend style="padding:0 8px;color:Red;">第 '+i;
            html += ' 次还片</legend>';
            html+='<table border="1" class="tables">';
            html+='<tr>';
            html += '<td class="tables_left"><div class="ty_div" id="hp_username">还片人：<span>' + o.HPName;
            html += '</span></div></td>';
            html += '<td><div class="ty_div" id="hp_aname">操作人：<span>' + o.AName;
            html += '</span></div></td>';
            html += '<td class="tables_right"><div class="ty_div" id="hp_adate">操作时间：<span>' + o.CreateDate;
            html += '</span></div></td>';
            html+='</tr>';
            html+='<tr>';
            html += '<td class="tables_left"><div class="ty_div" id="hp_bpcount">玻片数量：<span>' + o.BPCount;
            html += '</span></div></td>';
            html += '<td><div class="ty_div" id="hp_lkcount">蜡块数量：<span>' + o.LKCount;
            html += '</span></div></td>';
            html += '<td class="tables_right"><div class="ty_div" id="hp_pcode">仓位编码：<span>' + o.PIDText;
            html += '</span></div></td>';
            html+='</tr>';
            html+='<tr>';
            html += '<td class="tables_left"><div class="ty_div" id="hp_createdate">还片日期：<span>' + o.HPDate;
            html += '</span></div></td>';
            html += '<td><div class="ty_div">还片电话：<span>' + o.Mobile;
            html += '</span></div></td>';
            html += '<td class="tables_right"><div class="ty_div" id="hp_remarks">备注：<span>' + o.Remarks;
            html += '</span></div></td>';
            html+='</tr>';
            html+='</table>';
            html+='<div class="tyimg" style="padding-left:1%;">';
            html += '<div style="float:left;" class="dy_imgs">图片：</div>';
            html+='<div class="main">';
            html += '<div id="img_hp_' + i + '" class="img_panel_hp"><div id="img_panel_hp_' + i + '" class="imgview" style="margin-right:0px"></div><div id="add-photo_hp_' + i + '" class="add-photo_hp"></div></div>';
            html += '</div> ';
            html += '</div>';
            html += '</fieldset>';
            html += '</div>';

            $("#lists").append(html);
        }

        /*打印控件*/
        function myPreview2() {
            var ysid = $("#ys_id").html();
            var ucode = $("#ys_ucode").find("span").html();
            var experimentnumber = $("#ys_experimentnumber").find("span").html();
            var name = $("#ys_name").find("span").html();
            var bo = false;
            if (ucode != null && ucode != "") {
                bo = true;
            }
            if (experimentnumber != "" && name != "") {
                bo = true;
            }
            if (bo) {
                var htmls = document.getElementById("lists").innerHTML; //这是获取要打印的 html信息

                var data = {};
                data.act = "update_rawdata_prints";
                data.id = ysid;
                data.prints = "" + htmls + "";
                data.sign = GetSign(data.act);
                Ajax.Post("/tools/Admin.ashx", data, function (r) {
                    var json = $.parseJSON(r);
                    if (json.data > 0) {
                        window.open("/system/Print.aspx?id=" + json.data + "")
                    } else {
                        LayerBox.Error("没有查病人要打印的信息");
                    }
                });
            } else {
                LayerBox.Error("请选择要打印的病人信息");
            }

        };
 
</script>
</body>
</html>
